package com.ruoyi.web.controller.match;

import java.util.List;

import com.ruoyi.system.domain.match.BmMatchDetail;
import com.ruoyi.system.service.match.IBmMatchDetailService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 比赛详细信息Controller
 * 
 * @author xiangzhipeng
 * @date 2022-11-29
 */
@Controller
@RequestMapping("/match/detail")
public class BmMatchDetailController extends BaseController
{
    private String prefix = "match/detail";

    @Autowired
    private IBmMatchDetailService bmMatchDetailService;

    @RequiresPermissions("match:detail:view")
    @GetMapping()
    public String detail()
    {
        return prefix + "/detail";
    }

    /**
     * 查询比赛详细信息列表
     */
    @RequiresPermissions("match:detail:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BmMatchDetail bmMatchDetail)
    {
        startPage();
        List<BmMatchDetail> list = bmMatchDetailService.selectBmMatchDetailList(bmMatchDetail);
        return getDataTable(list);
    }

    /**
     * 导出比赛详细信息列表
     */
    @RequiresPermissions("match:detail:export")
    @Log(title = "比赛详细信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BmMatchDetail bmMatchDetail)
    {
        List<BmMatchDetail> list = bmMatchDetailService.selectBmMatchDetailList(bmMatchDetail);
        ExcelUtil<BmMatchDetail> util = new ExcelUtil<BmMatchDetail>(BmMatchDetail.class);
        return util.exportExcel(list, "比赛详细信息数据");
    }

    /**
     * 新增比赛详细信息
     */
    @GetMapping("/add/{matchId}")
    public String add(@PathVariable("matchId") String matchId, ModelMap mmap)
    {
        mmap.put("matchId",matchId);
        return prefix + "/add";
    }

    /**
     * 新增保存比赛详细信息
     */
    @RequiresPermissions("match:detail:add")
    @Log(title = "比赛详细信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BmMatchDetail bmMatchDetail)
    {
        return toAjax(bmMatchDetailService.insertBmMatchDetail(bmMatchDetail));
    }

    /**
     * 修改比赛详细信息
     */
    @RequiresPermissions("match:detail:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        BmMatchDetail bmMatchDetail = bmMatchDetailService.selectBmMatchDetailById(id);
        mmap.put("bmMatchDetail", bmMatchDetail);
        return prefix + "/edit";
    }

    /**
     * 修改保存比赛详细信息
     */
    @RequiresPermissions("match:detail:edit")
    @Log(title = "比赛详细信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BmMatchDetail bmMatchDetail)
    {
        return toAjax(bmMatchDetailService.updateBmMatchDetail(bmMatchDetail));
    }

    /**
     * 删除比赛详细信息
     */
    @RequiresPermissions("match:detail:remove")
    @Log(title = "比赛详细信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bmMatchDetailService.deleteBmMatchDetailByIds(ids));
    }
}
